package com.yang.concurrency.chapter5;

/**
 * @Author: 血魔
 * @Date: Created in 16:08 2021/12/12
 * @Version: $
 */
public class ThreadInterrupt {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread() {
            @Override
            public void run() {
                int i = 0;
                while (true){
                    try{
                        Thread.sleep(10000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("我爱你 陈瑾玉 + " + (i++));
                }
            }
        };

        t1.start();
        Thread.sleep(100);
        System.out.println(t1.isInterrupted());
        t1.interrupt(); //设置中断之后，如果子线程进入阻塞（等待 或者 超市等待）会报一次异常
        System.out.println(t1.isInterrupted());

    }
}
